local skill = fk.CreateSkill{
  name = "action__wushengguilai_skill",
}

Fk:loadTranslationTable{
  ["action__wushengguilai"] = "武圣归来",
  ["action__wushengguilai_skill"] = "武圣归来",
  [":action__wushengguilai"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：你 <br /><b>效果</b>：选择一名已死亡的角色令其复活。（不可响应）",
  ["#action__wushengguilai_skill"] = "选择一名已死亡的角色令其复活",
}


skill:addEffect("cardskill", {
  mute = true,
  name = "action__wushengguilai",
  prompt = "#action__wushengguilai_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    cardUseEvent.disresponsiveList = table.simpleClone(Fk:currentRoom().players)
    if not cardUseEvent.tos or #cardUseEvent.tos == 0 then
      cardUseEvent.tos = { cardUseEvent.from }
    end
  end,
  on_effect = function(self, room, effect)
    local tos = table.map(table.filter(room.players, function(p) return p.dead end), function(p) return "seat#" .. tostring(p.seat) end)
    if #tos > 0 then
      local targets = room:askToChoice(effect.to, {choices = tos, skill_name = self.name, prompt = "复活一名已死亡的角色！"})
      if targets then
        local to = tonumber(string.sub(targets, 6))
        for _, p in ipairs(room.players) do
          if p.seat == to then
            room:revivePlayer(p, true)
            if p.maxHp <= 0 then
              room:setPlayerProperty(p, "maxHp", 3)
            end
            room:setPlayerProperty(p, "hp", 1)
            room:drawCards(p, 3)
            break
          end
        end
      end
    end
  end,
})


return skill